package com.topisv.tms.utils;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.topisv.tms.service.vo.TimeValue;
import com.topisv.tms.utils.date.TopIsvDateUtils;

public abstract class TransportTimeUtil {

	public static List<TimeValue> getListTimes(Date date) throws ParseException {
		List<TimeValue> times = new ArrayList<TimeValue>();
		Date nowDate=new Date();
		boolean fal=true;
		for (int i = -3; i < 4; i++) {
			TimeValue timeValue=new TimeValue();
			Date tempDate = TopIsvDateUtils.addDays(date, i);
			String dateString=TimeUtil.getNowDateString(tempDate);
			tempDate=TimeUtil.getDate(dateString);
			if(tempDate.getTime()<=nowDate.getTime()){
				timeValue.setValue(tempDate.toString());
				String nowDateTemp=TimeUtil.getNowDateStringDD(nowDate);
				String dataTemp=dateString.substring(0, 10);
				if(nowDateTemp.equals(dataTemp)){
					timeValue.setParam("今天");
					fal=false;
				}else{
					Date yesterDay = TopIsvDateUtils.addDays(nowDate, -1);//减少一天
					nowDateTemp=TimeUtil.getNowDateStringDD(yesterDay);
					if(nowDateTemp.equals(dataTemp)){
						timeValue.setParam("昨天");
					}else{
						timeValue.setParam(dateString.substring(0, 10));
					}
				}
				times.add(timeValue);
			}
		}
		
		if(fal){
			TimeValue timeValue=new TimeValue();
			String dateString=TimeUtil.getNowDateString(nowDate);
			nowDate=TimeUtil.getDate(dateString);
			timeValue.setValue(nowDate.toString());
			timeValue.setParam("今天");
			times.add(timeValue);
		}
		return times;
	}
}
